package com.cw.DesignModel23.Structural.DecoratorPattern.Decorator2;

import com.cw.DesignModel23.Structural.DecoratorPattern.Decorator2.Drink.Drink;

/**
 * ****装饰物，继承了Drink，还聚合了Drink*****
 */
public class Decorator extends Drink {
    private Drink obj;

    /**
     * 聚合Drink
     * @param obj
     */
    public Decorator(Drink obj) {
        this.obj = obj;
    }

    @Override
    public float cost() {
        // getPrice 自己价格 + 咖啡的价格
        return super.getPrice() + obj.cost();
    }

    /**
     * 输出信息
     * @return
     */
    @Override
    public String getDes() {
        // obj.getDes() 输出被装饰者的信息
        return des + " " + getPrice() + " && " + obj.getDes();
    }

}

